<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>通道管理</title>
	
	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#partition_name").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate();
		});
		var sp_id = "";
		function createPipe(storagePartition_id)
		{
			sp_id = storagePartition_id;
			$("#shelf_num").val("");
		}
		
		function addPipe() {
			var shelf_num = $("#shelf_num").val();
			var shelf_type = $("#shelf_type").val();
			$.ajax({
				type : 'post',
				url : '${ctx}/v2/storage/addPipe',
				data : 'storagePartition_id=' + sp_id  + '&shelf_num=' + shelf_num + '&shelf_type=' + shelf_type,
				dataType : 'json',
				success : function(data) {
					if (data.status == "1") {
						alert("创建成功");
					} else if (data.status == "0") {
						//alert("创建失败！");
					}
				},
				error : function() {
				}
			});
		}
	</script>
</head>

<body>
	<form id="inputForm" action="${ctx}/v2/storage/updatePartition" method="post" class="form-horizontal">
		<input type="hidden" name="id" value="${storagePartition.id}"/>
		<fieldset>
			<legend><small>管理分区</small></legend>
			<div class="control-group">
				<label for="partition_name" class="control-label">分区名称:</label>
				<div class="controls">
					<input type="text" id="partition_name" name="partition_name"  value="${storagePartition.partition_name}" class="input-large required" minlength="1"/>
				</div>
			</div>
			<div class="control-group">
				<label for="partition_code" class="control-label">分区编码:</label>
				<div class="controls">
					<input type="text" id="partition_code" name="partition_code"  value="${storagePartition.partition_code}" class="input-large required" minlength="1"/>
				</div>
			</div>
			<div class="control-group">
				<label for="partition_remark" class="control-label">分区备注:</label>
				<div class="controls">
					<input type="text" id="partition_remark" name="partition_remark"  value="${storagePartition.partition_remark}" class="input-large required" minlength="1"/>
				</div>
			</div>
			<c:if test="${not empty storagePipes}">
			<div class="control-group">
				<label for="storage_areagroupId" class="control-label">所有通道:</label>
				<div class="controls">
					<c:forEach items="${storagePipes}" var="storagePipe">
						 <div class="btn-group dropup">
						    	<a href="#" role="button" onclick="" class="btn" data-toggle="modal">通道${storagePipe.pipe_name}</a>
							    <button class="btn dropdown-toggle" data-toggle="dropdown">
							    	<span class="caret"></span>
							    </button>
							    <ul class="dropdown-menu">
							    	<li><a href="${ctx}/v2/storage/storagePipe/${storagePipe.id}/1">查看aaa</a></li>
							    	<li><a href="${ctx}/v2/storage/storagePipe/${storagePipe.id}/1">删除</a></li>
							    </ul>
							 </div>
							 <br />
					</c:forEach>
				</div>
			</div>
			</c:if>
			<div class="form-actions">
				<a href="#storage_pipe" role="button" onclick="createPipe('${storagePartition.id}');" class="btn" data-toggle="modal">创建通道</a>
				<input id="submit_btn" class="btn btn-primary" type="submit" value="提交"/>&nbsp;	
				<input id="cancel_btn" class="btn" type="button" value="返回" onclick="history.back()"/>
			</div>
		</fieldset>
	</form>
	<div style="display: none; width: 1000" class="modal hide fade"
			tabindex="-1" role="dialog" aria-labelledby="myModalLabel1"
			aria-hidden="true" id="storage_pipe">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">
					×
				</button>
				<h3 id="myModalLabel1">
					分区
				</h3>
			</div>
			<div class="modal-body">
				<table class="table table-striped table-bordered table-condensed"
					id="expressStatus_tab">
					<!--<tr>
						<td>
							通道名称
						</td>
						<td>
							<input type="text" id="pipe_name" name="pipe_name"  value="" />
						</td>
					</tr>
					<tr>
						<td>
							通道编码
						</td>
						<td>
							<input type="text" id="pipe_code" name="pipe_code"  value="" />
						</td>
					</tr>
					--><tr>
						<td>
							货架类型
						</td>
						<td>
							<select id="shelf_type" name="shelf_type" >
								<c:forEach items="${goodsShelfs}" var="goodsShelf">
									<option value="${goodsShelf.shelf_code}">${goodsShelf.shelf_name}</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							货架个数
						</td>
						<td>
							<input type="text" id="shelf_num" name="shelf_num"  value="" />
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button class="btn" onclick="addPipe();" data-dismiss="modal" aria-hidden="true">
					确定
				</button>
			</div>
		</div>
</body>
</html>
